<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Dao\SetDao;
use Hyperf\Di\Annotation\Inject;

class IndexController extends AbstractController
{
    /**
     * @Inject()
     * @var SetDao
     */
    private $setDao;

    public function index()
    {
        $user = $this->request->input('user', 'Hyperf');
        $method = $this->request->getMethod();

        return [
            'mets' => $method,
            'message' => "Hello {$user}.",
            'password' => password_hash('pxx123admin',PASSWORD_BCRYPT )
        ];
    }


    /**
     * 获得
     */
    public function getById($id=1)
    {

        try {
            $set = $this->setDao->getById($id);
            return $this->response->success('获得成功', [
                'id' => $set->id,
                'urls' => $set->urls,
                'banners' => $set->banners
            ]);

        } catch (\Exception $e) {
            return $this->response->error($e->getMessage());
        }
    }
}
